package mail.bean;

import java.io.File;
import java.util.ArrayList;
import java.util.Properties;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;


public class AccountBean {
  private String accountName;
  private String accountAddress;
  private String recHost;
  private String recProtocol;
  private String sendHost;
  private String sendProtocol;
  private String recPort;
  private String sendPort;
  private String sslSocletFactory;
  private String user;
  private String pwd;
  private String host;
  private boolean needAuth;
  private boolean smtpUseSSH;
  private boolean pop3UseSSH;
  private Properties env = null;
  private String saveFolder = null;
  private ArrayList<EmailBean> mailList = null;
  private ArrayList<String> uidList = null;
  public String getSaveFolder() {
    return saveFolder;
  }

  public void setSaveFolder(String saveFolder) {
    this.saveFolder = saveFolder;
  }

  public static final String INBOX = "inbox";
  public static final String OUTBOX = "outbox";
  public static final String SENTITEMS = "sent items";
  public static final String DELETEITEMS = "delete items";
  public static final String DRAFTS = "drafts";
  
  public String toString() {
    return new StringBuilder("name:").append(accountName).
        append("\n address:").append(accountAddress).
        append("\n recHost:").append(recHost).
        append("\n recProtocol:").append(recProtocol).
        append("\n sendHost:").append(sendHost).
        append("\n sendProtocol:").append(sendProtocol).
        append("\n recPort:").append(recPort).
        append("\n sendPort:").append(sendPort).
        append("\n sslSocletFactory:").append(sslSocletFactory).
        append("\n user:").append(user).
        append("\n pwd:").append("******").
        append("\n host:").append(host).
        append("\n needAuth:").append(needAuth).
        append("\n pop3UseSSH:").append(pop3UseSSH).
        append("\n smtpUseSSH:").append(smtpUseSSH).toString();
  }
  
  public String getAccountAddress() {
    return accountAddress;
  }

  public void setAccountAddress(String accountAddress) {
    this.accountAddress = accountAddress;
  }

  public String getRecPort() {
    return recPort;
  }

  public void setRecPort(String recPort) {
    this.recPort = recPort;
  }

  public String getSendPort() {
    return sendPort;
  }

  public void setSendPort(String sendPort) {
    this.sendPort = sendPort;
  }

  public String getSslSocletFactory() {
    return sslSocletFactory;
  }

  public void setSslSocletFactory(String sslSocletFactory) {
    this.sslSocletFactory = sslSocletFactory;
  }

  public boolean isSmtpUseSSH() {
    return smtpUseSSH;
  }

  public void setSmtpUseSSH(boolean smtpUseSSH) {
    this.smtpUseSSH = smtpUseSSH;
  }

  public boolean isPop3UseSSH() {
    return pop3UseSSH;
  }

  public void setPop3UseSSH(boolean pop3UseSSH) {
    this.pop3UseSSH = pop3UseSSH;
  }

  private ArrayList<String> folderList = new ArrayList<String>();
  
  public AccountBean(String accountName) {
    this.accountName = accountName;
    folderList.add(INBOX);
    folderList.add(OUTBOX);
    folderList.add(SENTITEMS);
    folderList.add(DELETEITEMS);
    folderList.add(DRAFTS);
  }

  public String getAccountName() {
    return accountName;
  }

  public void setAccountName(String accountName) {
    this.accountName = accountName;
  }

  public ArrayList<String> getFolderList() {
    return folderList;
  }

  public void setFolderList(ArrayList<String> folderList) {
    this.folderList = folderList;
  }
  
  public DefaultMutableTreeNode toTree() {
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(this.accountName);
    if(folderList.size() > 0) {
      DefaultMutableTreeNode child = null;
      for(String folder : folderList) {
        child = new DefaultMutableTreeNode(folder);
        parent.add(child);
      }
    }
    return parent;
  }

public String getPwd() {
	return pwd;
}

public void setPwd(String pwd) {
	this.pwd = pwd;
}

public String getRecHost() {
	return recHost;
}

public void setRecHost(String recHost) {
	this.recHost = recHost;
}

public String getRecProtocol() {
	return recProtocol;
}

public void setRecProtocol(String recProtocol) {
	this.recProtocol = recProtocol;
}

public String getSendHost() {
	return sendHost;
}

public void setSendHost(String sendHost) {
	this.sendHost = sendHost;
}

public String getSendProtocol() {
	return sendProtocol;
}

public void setSendProtocol(String sendProtocol) {
	this.sendProtocol = sendProtocol;
}

public String getUser() {
	return user;
}

public void setUser(String user) {
	this.user = user;
}

public String getHost() {
	return host;
}

public void setHost(String host) {
	this.host = host;
}

public boolean isNeedAuth() {
	return needAuth;
}

public void setNeedAuth(boolean needAuth) {
	this.needAuth = needAuth;
}

public Properties getEnv() {
  return env;
}

public void setEnv(Properties env) {
  this.env = env;
}

public ArrayList<EmailBean> getMailList() {
  return mailList;
}

public void setMailList(ArrayList<EmailBean> mailList) {
  this.mailList = mailList;
}

public ArrayList<String> getUidList() {
  return uidList;
}

public void setUidList(ArrayList<String> uidList) {
  this.uidList = uidList;
}
}
